package com.wjm.demo.test1.net_test.tcp_socket_test.uploadtext;

import java.io.*;
import java.net.Socket;

public class UploadClient {
    public static void main(String[] args) throws Exception {
        Socket s = new Socket("192.168.0.101", 10001);
        File file = new File("d:\\新建文本文档.txt");
        System.out.println(file.exists());
        BufferedReader br = new BufferedReader(new FileReader(file));
        PrintWriter pw = new PrintWriter(s.getOutputStream(), true);
        String line = null;
        while ((line = br.readLine()) != null) {
            pw.println(line);
        }
//        pw.println("over");
        s.shutdownOutput();//结束标记
        BufferedReader brServerInputStream = new BufferedReader(new InputStreamReader(s.getInputStream()));
        String readLine = brServerInputStream.readLine();
        System.out.println(readLine);
        br.close();
        s.close();
    }
}
